package sqlServer;

import java.util.HashMap;

import javaUtils.DateUtils;

public class Menus extends BaseDataObject {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3672404349139019097L;
	public static final int MENUS_ID = 1;
	public static final int MENU_TYPE_ID = 2;
	public static final int PUBLICHED_FROM = 3;
	public static final int PUBLICHED_TO = 4;
	public static final int PUBLICHED = 5;
	public static final int MENU_POSITION = 6;
	public static final int MENU_NAME = 7;
	public static final int MAX_SUBCATEGORIES = 8;
	public final static int OBJECT_TYPE = 9;
	private int menuId;
	private int menuTypeId;
	private String publichedFrom;
	private String publichedTo;
	private int publiched;
	private String menuPosition;
	private String menuName;
	private String objectType = "menu";
	private int maxSubcategories;
	private HashMap <Integer, Menus> menuHistory = new HashMap<Integer, Menus>();
	
	public Menus() {
		setObjectType("menu");
	}
	
	public void setMenu(int param, String paramValue){
		switch(param){
		case PUBLICHED_FROM: publichedFrom = paramValue; break;
		case PUBLICHED_TO: publichedTo = paramValue; break;
		case MENU_POSITION: menuPosition = paramValue; break;
		case MENU_NAME: menuName = paramValue; break;
		}
	}
	
	public void setMenu(int param, int paramValue){
		switch(param){
		case MENUS_ID: menuId = paramValue; setObjectId(paramValue); break; 
		case MENU_TYPE_ID: menuTypeId = paramValue; break;
		case PUBLICHED: publiched = paramValue; break;
		case MAX_SUBCATEGORIES: maxSubcategories = paramValue; break;
		}
	}
	
	public String getMenuItem(int param){
		String paramValue = null;
		switch(param){
		case PUBLICHED_FROM: paramValue = publichedFrom; break;
		case PUBLICHED_TO: paramValue = publichedTo; break;
		case MENUS_ID: paramValue = Integer.toString(menuId); break;
		case MENU_TYPE_ID: paramValue = Integer.toString(menuTypeId); break;
		case PUBLICHED: paramValue = Integer.toString(publiched); break;
		case MENU_POSITION: paramValue = menuPosition; break;
		case MENU_NAME: paramValue = menuName; break;
		case MAX_SUBCATEGORIES: paramValue = Integer.toString(maxSubcategories); break;
		case OBJECT_TYPE: paramValue = objectType; break;
		}
		return paramValue;
	}
	
	public void createNewMenu(AppConnection applicationConnect, Object parentObject, int order){
		publichedFrom = DateUtils.getDateTime();
		publichedTo = null;
		publiched = 0;
		menuPosition = "New";
		menuTypeId = 2;
		applicationConnect.insertNewMenu(parentObject,this,order);		
	}
	
	public String toString() { 
		String menuName = this.menuName;
		if(menuName == null)
			menuName = "";
		return menuPosition+" Menu "+menuName;
    }
	public void addMenuHisotry(Menus menu){
		menuHistory.put(menuHistory.size()+1, menu);
	}
}